package io.gitee.welson.sensitive.config;

import io.gitee.welson.sensitive.enums.OverflowStrategy;
import org.springframework.boot.context.properties.ConfigurationProperties;

/**
 * 敏感数据导出配置属性
 *
 * @author welson
 */
@ConfigurationProperties(prefix = "sensitive.export")
public class SensitiveExportProperties {

    /**
     * 是否启用敏感数据导出功能，默认启用，该属性为false时，不会进行自动装配
     */
    private boolean enabled = true;

    /**
     * 是否启用全局脱敏，默认启用
     * 当设置为false时，即使字段上标注了@SensitiveField注解，也不会进行脱敏处理
     */
    private boolean sensitiveEnabled = true;

    /**
     * 单个Sheet页数据行数上限，默认100_0000行
     * 此配置为限制值，用于防止单个Sheet页数据量过大：
     * 1. 导出服务会确保单个Sheet页不会超过此行数
     * 2. 是否分页由具体的导出方法决定
     * 3. 超出时根据溢出策略处理
     */
    private int sheetMaxRows = 100_0000;

    /**
     * 全局溢出策略，默认为抛出异常
     * 注意：多sheet页导出时不支持分页策略，如果设置了分页策略会抛出异常
     */
    private OverflowStrategy overflowStrategy = OverflowStrategy.THROW_EXCEPTION;

    /**
     * 导出文件默认后缀名，默认为xlsx
     */
    private String defaultSuffix = ".xlsx";

    /**
     * 导出文件默认编码，默认为UTF-8
     */
    private String defaultEncoding = "UTF-8";

    public boolean isEnabled() {
        return enabled;
    }

    public void setEnabled(boolean enabled) {
        this.enabled = enabled;
    }

    public boolean isSensitiveEnabled() {
        return sensitiveEnabled;
    }

    public void setSensitiveEnabled(boolean sensitiveEnabled) {
        this.sensitiveEnabled = sensitiveEnabled;
    }

    public int getSheetMaxRows() {
        return sheetMaxRows;
    }

    public void setSheetMaxRows(int sheetMaxRows) {
        this.sheetMaxRows = sheetMaxRows;
    }

    public OverflowStrategy getOverflowStrategy() {
        return overflowStrategy;
    }

    public void setOverflowStrategy(OverflowStrategy overflowStrategy) {
        this.overflowStrategy = overflowStrategy;
    }

    public String getDefaultSuffix() {
        return defaultSuffix;
    }

    public void setDefaultSuffix(String defaultSuffix) {
        this.defaultSuffix = defaultSuffix;
    }

    public String getDefaultEncoding() {
        return defaultEncoding;
    }

    public void setDefaultEncoding(String defaultEncoding) {
        this.defaultEncoding = defaultEncoding;
    }
}